Skip to content

gmoccapy: exit cleanly on termination signal instead of error dialog#4076

Open
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/gmoccapy-sigterm-clean-exit
Open

gmoccapy: exit cleanly on termination signal instead of error dialog#4076
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/gmoccapy-sigterm-clean-exit

Conversation

@grandixximo
Copy link
Copy Markdown
Contributor

gmoccapy did not exit on SIGTERM; callers had to escalate to SIGKILL.

PyGObject's signal bridge surfaces a termination signal into the GTK main
loop as a Python KeyboardInterrupt. That reached the installed sys.excepthook,
which unconditionally popped a modal "Found an error ... KeyboardInterrupt"
dialog and blocked in the dialog's nested loop, so the process never quit.

Handle KeyboardInterrupt at the top of excepthook: log it and quit the main
loop instead of showing the modal dialog. The old broken
except KeyboardInterrupt on the window lookup (which could never fire there)
is removed.

Surfaced in the ui-smoke review, PR #4054.

Fixes #4069

Test: SIGTERM to the gmoccapy sim under xvfb. Verified with py-spy that the
process is in the real Gtk.main loop and now exits cleanly, with no SIGKILL
escalation and no error-dialog traceback.

gmoccapy did not exit on SIGTERM; callers had to escalate to SIGKILL.

Root cause: PyGObject's signal bridge surfaces a termination signal into
the GTK main loop as a Python KeyboardInterrupt. That propagated to the
installed sys.excepthook, which unconditionally popped a modal
'Found an error ... KeyboardInterrupt' dialog and blocked in the dialog's
nested loop, so the process never quit.

Handle KeyboardInterrupt at the top of excepthook: log it and quit the
main loop instead of showing the modal error dialog. Verified that
gmoccapy now exits cleanly on SIGTERM (no SIGKILL escalation, no spurious
error-dialog traceback). The previous broken 'except KeyboardInterrupt'
on the window lookup (which could never fire there) is removed.

Surfaced by the ui-smoke tests (PR LinuxCNC#4054).

Fixes LinuxCNC#4069
grandixximo added a commit to grandixximo/linuxcnc that referenced this pull request Jun 1, 2026
Adds a quit-path smoke test per GUI that boots the GUI, waits for the
NML task to come up, sends SIGTERM to the GUI process alone, and asserts
the GUI exits on its own within a short grace. This guards the
clean-shutdown handlers: a GUI that absorbs SIGTERM and has to be
SIGKILLed fails the test.

The new _lib/quit-launch.sh shares the headless environment (software
GL + audio silencing) with launch.sh by sourcing a new
_lib/launch-env.sh rather than copying it, so the two launchers cannot
drift apart. Results go through _lib/checkresult-quit.sh (pass on
UI_SMOKE_QUIT_OK). The GUI process is identified by matching a python
argv[0], so the linuxcnc launcher and xvfb-run wrappers that also carry
the GUI name on their command line are not mistaken for it. Per-GUI
dirs: touchy-quit, gmoccapy-quit, qtdragon-quit.

The qtdragon quit test needs the same CI workarounds the qtdragon smoke
test already carries (writable config mirror with a patched LOG_FILE,
the offscreen Qt platform, and the QtWebEngine import shim). Those move
out of qtdragon/test.sh into _lib/qtdragon-prepare.sh, sourced by both
qtdragon test.sh files, so the quit test reuses them instead of leaving
qtvcp to crash on startup.

Requires the SIGTERM handlers in LinuxCNC#4076 (gmoccapy), LinuxCNC#4077 (touchy) and
LinuxCNC#4078 (qtvcp); without them the GUIs ignore SIGTERM and these tests
fail by design.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gmoccapy: does not exit on SIGTERM (swallows it as KeyboardInterrupt)

2 participants